import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'vtrade'
})
export class VtradePipe implements PipeTransform {

  static StaticDict = {
    entrust_status: {
      0: "未报",
      1: "待报",
      2: "已报",
      3: "已报待撤",
      4: "部成待撤",
      5: "部撤",
      6: "已撤",
      7: "部成",
      8: "已成",
      9: "废单"
    },
    withdraw_flag: {
      0: "不允许撤单",
      1: "允许",
      2: "仅允许撤单申报",
    },
    entrust_bs: {
      1: "买入",
      2: "卖出"
    }
  };

  transform(value: string, type: string) {
    if (!type ||
      !(type in VtradePipe.StaticDict && value in VtradePipe.StaticDict[type]) ||
      value === undefined ||
      value === "-"
    ) return value;
    return (VtradePipe.StaticDict[type][value]);
  }

}